<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .wrapper {
            display: grid; /* 声明按grid布局 */
            grid-gap: 20px; /* 声明grid内元素间距 */
            grid-template-columns: 1fr 4fr; /* 声明2列，比重1:4 */
            grid-template-areas: /* 声明区块占用 */
                    "a a"
                    "b c"
                    "d d";
        }
        .wrapper > div {
            padding: 20px;
            border: 2px solid red;
            background-color: #ffec99;
        }
        .header {
            grid-area: a; /* 声明区块名称 */
        }
        .sidebar {
            grid-area: b;
        }
        .main {
            grid-area: c;
        }
        .footer {
            grid-area: d;
        }
        /* 当宽度小于600px时 */
        @media (max-width: 600px) {
            .wrapper {
                grid-template-columns: auto; /* 变为一列 */
                grid-template-areas: /* 一列的布局 */
                        "a"
                        "b"
                        "c"
                        "d";
            }
        }
    </style>
</head>
<body>
<p>当浏览器视窗小于600时，布局改变</p>
<div class="wrapper">
    <div class="header">One(a)</div>
    <div class="sidebar">Two(b)</div>
    <div class="main">Three(c)</div>
    <div class="footer">Four(d)</div>
</div>
</body>
</html>